package com.多线程基础.常用方法.获取名称方法;

public class MyThread extends Thread{

    public MyThread() {
    }

    public MyThread(String name) {//带有名称的
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            //只能try，不能抛出
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            System.out.println(getName()+"   "+"helloword");
        }
    }
}
